
// ************************************
// * GStore - Inventory System - thomasfn *
// ************************************
// SHARED

ITEM.Base = "base_container"

ITEM.Classname = "inventory"
ITEM.Printname = "Player Inventory"

ITEM.Description = "The items a player holds are stored in here."
ITEM.Author = "thomasfn"

ITEM.Weight = 0
ITEM.Model = "items/error.mdl"

ITEM.Radius = 2

ITEM.CanPickup = false
ITEM.CanDrop = false
ITEM.DropOnDeath = false
ITEM.CanUse = false

ITEM.MassLimit = 5
ITEM.ItemLimit = 10

ITEM.NoDistanceRequirement = true

if (SERVER) then

	function ITEM:GetPos()
		return (ValidEntity( self.Owner ) and self.Owner:GetShootPos()) or self.RootBase.GetPos( self )
	end

	function ITEM:RemoveItem( item )
		self.ContainerBase.RemoveItem( self, item )
		item:OnDrop( self.Owner )
	end
	
	function ITEM:CanHoldItem_Reason( item )
		if (item:GetMass() > (self.MassLimit-self:GetMass())) then return "Item too heavy!" end
		if (#self.Items >= self.ItemLimit) then return "Your inventory is full!" end
		if (item.IsContainer && (!item:IsEmpty())) then return "Item must be empty!" end
		if (!item.InWorld) then return "You can't pick that up!" end
		return ""
	end
	
	function ITEM:Manifest()
		self.ContainerBase.Manifest( self )
		umsg.Entity( self.Owner )
	end

end

if (CLIENT) then
	
	function ITEM:GetPos()
		return LocalPlayer():GetShootPos()
	end
	
	function ITEM:Update( um )
		self.ContainerBase.Update( self, um )
		self.Owner = um:ReadEntity()
		if (self.Owner == LocalPlayer()) && UpdateInventories then
			UpdateInventories( self )
		end
	end

end